package edu.webtek.clouddata;

import org.jdom2.Element;

public class Sale {
	private final long saleTime, saleAmount, shopID, itemID, customerID, saleItemPrice;
	public long getSaleTime() {
		return saleTime;
	}

	public long getSaleAmount() {
		return saleAmount;
	}

	public long getShopID() {
		return shopID;
	}

	public long getItemID() {
		return itemID;
	}

	public long getCustomerID() {
		return customerID;
	}

	public long getSaleItemPrice() {
		return saleItemPrice;
	}
	
	public Sale(Element sale) {
		long saleTime, saleAmount, shopID, itemID, customerID, saleItemPrice;
		saleTime = saleAmount = shopID = itemID = customerID = saleItemPrice = -1;
		
		for(Element attr : sale.getChildren()){
			long data = Long.parseLong(attr.getText());
			switch(attr.getName()){
			case "saleTime":
				saleTime = data;
				break;
			case "saleAmount":
				saleAmount = data;
				break;
			case "shopID":
				shopID = data;
				break;
			case "itemID":
				itemID = data;
				break;
			case "customerID":
				customerID = data;
				break;
			case "saleItemPrice":
				saleItemPrice = data;
				break;
			}
		}
		
		this.saleTime 	 = saleTime;
		this.saleAmount = saleAmount;
		this.shopID = shopID;
		this.itemID = itemID;
		this.customerID =  customerID;
		this.saleItemPrice = saleItemPrice;
	}

	@Override
	public String toString() {
		return "Sale [saleTime=" + saleTime + ", saleAmmount=" + saleAmount
				+ ", shopID=" + shopID + ", itemID=" + itemID
				+ ", custommerID=" + customerID + ", saleItemPrice="
				+ saleItemPrice + "]";
	}
	
	
	
}
